package com.wit.witmg.api;


import com.wit.witmg.service.ITOrderService;
import com.wit.witmg.service.ITOrgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author bob
 * @since 2025-02-14
 */
@RestController
@RequestMapping("order")
@Api(tags = "订单API")
public class OrderController {
    @Resource
    private ITOrderService service;

    //参数(json，prod),id为空新增(同时根据prod数组新增订单分解表)，否则为修改（同时根据prod数组修改订单分解表）;参数id删除。
    @ApiOperation("添加")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json,
                      @RequestParam("prod") String prod) {
        return service.add(request,json,prod);
    }

    @ApiOperation("获取")
    @PostMapping("get")
    public Object get(HttpServletRequest request,//参数：cid客户id返回cid对应的数据、oid返回oid以参数开头并包含参数的数据；id返回单条数据，常用于连表查询。
                      @RequestParam(value = "id",required = false) Integer id,
                      @RequestParam(value = "cbn",required = false) String cbn,
                      @RequestParam(value = "oid",required = false) String oid,
                      @RequestParam(value = "stat",required = false) String stat
    ) {
        return service.get(request,id,cbn,oid,stat);
    }

//    @ApiOperation("删除")
//    @PostMapping("del")
//    public Object del(HttpServletRequest request,
//                      @RequestParam("id") Integer id) {
//        return service.del(request,id);
//    }
}
